#include <iostream>
#include <string>
#include "myarray.hpp"
using namespace std;

void test1()
{
    // 字符类型数组测试
    cout << "============== char arr ================" << endl;
    MyArray<char> c_arr(10);
    c_arr.push_back('a');
    c_arr.push_back('b');
    c_arr.push_back('c');
    c_arr.push_back('d');
    c_arr.push_back('e');
    cout << "arr size: " << c_arr.size() << " cap: " << c_arr.capacity() << endl;
    cout << "arr[3] = " << c_arr[3] << endl;
    c_arr.pop_back();
    cout << "arr size: " << c_arr.size() << " cap: " << c_arr.capacity() << endl;

    MyArray<char> c_arr2 = c_arr;
    cout << "arr2 size: " << c_arr2.size() << " cap: " << c_arr2.capacity() << endl;
}

class Persion
{
public:
    Persion() {}
    Persion(string name, int age)
    {
        m_name = name;
        m_age - age;
    }
    void show()
    {
        cout << "name: " << m_name << " age: " << m_age << endl;
    }

public:
    string m_name;
    int m_age;
};

void test2()
{
    // 自定义类型测试
    cout << "================== customize(class) arr ======================" << endl;
    MyArray<Persion> p_arr(10);
    Persion p1("monkey", 1000);
    Persion p2("pig", 100);
    Persion p3("sha", 500);
    p_arr.push_back(p1);
    p_arr.push_back(p2);
    p_arr.push_back(p3);
    cout << "arr size: " << p_arr.size() << " cap: " << p_arr.capacity() << endl;

    cout << "arr[3] = " << p_arr[2].m_name << endl;
    p_arr.pop_back();
    cout << "arr size: " << p_arr.size() << " cap: " << p_arr.capacity() << endl;

    MyArray<Persion> p_arr2 = p_arr;
    cout << "arr2 size: " << p_arr2.size() << " cap: " << p_arr2.capacity() << endl;
};

int main()
{
    test1();
    test2();
    return 0;
}